package com.ding.dailyup.repository;

import java.util.Optional;

import javax.persistence.LockModeType;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Lock;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.QueryByExampleExecutor;
import org.springframework.stereotype.Repository;

import com.ding.dailyup.model.UserInfo;

@Repository
public interface UserInfoRepository extends JpaRepository<UserInfo, Long>,
		PagingAndSortingRepository<UserInfo, Long>,
		QueryByExampleExecutor<UserInfo> {

	Optional<UserInfo> findByWeixinOpenid(String openId);

	@Lock(LockModeType.PESSIMISTIC_WRITE)
	Optional<UserInfo> findUpdateById(Long userId);
}
